<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>上传设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
</head>
<body>
<div class="layui-fluid">
	<form class="layui-form" style="padding-bottom: 45px;">
		<div class="layui-card">
			<div class="layui-card-body">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">上传设置</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-form-item">
								<label class="layui-form-label">上传大小：</label>
								<div class="layui-input-inline w120">
									<select name="m_upsize">
										<option value="1" {eq name="$upload.upsize" value="1"}selected{/eq}>1M</option>
										<option value="2" {eq name="$upload.upsize" value="2"}selected{/eq}>2M</option>
										<option value="5" {eq name="$upload.upsize" value="5"}selected{/eq}>5M</option>
										<option value="10" {eq name="$upload.upsize" value="10"}selected{/eq}>10M</option>
										<option value="20" {eq name="$upload.upsize" value="20"}selected{/eq}>20M</option>
										<option value="50" {eq name="$upload.upsize" value="50"}selected{/eq}>50M</option>
										<option value="100" {eq name="$upload.upsize" value="100"}selected{/eq}>100M</option>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">允许上传类型：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_uptype" lay-verify="required" placeholder="请输入允许上传类型" class="layui-input" value="{$upload.uptype}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 如：jpg,gif,png,bmp,rar,zip</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">上传保存位置：</label>
								<div class="layui-input-inline w120">
									<select name="m_uplocation" lay-filter="m_location">
										<option value="1" {eq name="$upload.uplocation" value="1"}selected{/eq}>本地</option>
										<option value="2" {eq name="$upload.uplocation" value="2"}selected{/eq}>七牛云</option>
										<option value="3" {eq name="$upload.uplocation" value="3"}selected{/eq}>腾讯云</option>
										<option value="4" {eq name="$upload.uplocation" value="4"}selected{/eq}>阿里云</option>
									</select>
								</div>
							</div>
							<div id="span_qiniu" {neq name="$upload.uplocation" value="2"}style="display: none"{/neq}>
							<div class="layui-form-item">
								<label class="layui-form-label">AK：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qiniu_ak" placeholder="请输入AK" class="layui-input" value="{$upload.qiniu_ak}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">SK：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qiniu_sk" placeholder="请输入SK" class="layui-input" value="{$upload.qiniu_sk}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Bucket：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qiniu_bucket" placeholder="请输入Bucket" class="layui-input" value="{$upload.qiniu_bucket}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 空间名称</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Domain：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qiniu_domain" placeholder="请输入Domain" class="layui-input" value="{$upload.qiniu_domain}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 访问域名(http://或https://开头)</div>
							</div>
						    </div>
							<div id="span_qcloud" {neq name="$upload.uplocation" value="3"}style="display: none"{/neq}>
							<div class="layui-form-item">
								<label class="layui-form-label">AppId：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qcloud_appId" placeholder="请输入AppId" class="layui-input" value="{$upload.qcloud_appId}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">SecretId：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qcloud_secretId" placeholder="请输入SecretId" class="layui-input" value="{$upload.qcloud_secretId}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">SecretKey：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qcloud_secretKey" placeholder="请输入secretKey" class="layui-input" value="{$upload.qcloud_secretKey}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Bucket：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qcloud_bucket" placeholder="请输入Bucket" class="layui-input" value="{$upload.qcloud_bucket}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 存储桶名称</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Region：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qcloud_region" placeholder="请输入Region" class="layui-input" value="{$upload.qcloud_region}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 地域(如：ap-chengdu)</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Domain：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_qcloud_cosUrl" placeholder="请输入Domain" class="layui-input" value="{$upload.qcloud_cosUrl}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 访问域名(http://或https://开头)</div>
							</div>
							</div>
							<div id="span_ali" {neq name="$upload.uplocation" value="4"}style="display: none"{/neq}>
							<div class="layui-form-item">
								<label class="layui-form-label">AccessKeyId：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_ali_accessKeyId" placeholder="请输入AccessKeyId" class="layui-input" value="{$upload.ali_accessKeyId}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">AccessKeySecret：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_ali_accessKeySecret" placeholder="请输入AccessKeySecret" class="layui-input" value="{$upload.ali_accessKeySecret}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span></div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Endpoint：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_ali_endpoint" placeholder="请输入Endpoint" class="layui-input" value="{$upload.ali_endpoint}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 地域节点</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">Bucket：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_ali_bucket" placeholder="请输入Bucket" class="layui-input" value="{$upload.ali_bucket}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 存储空间名称</div>
							</div>
							<div class="layui-form-item" style="display: none;">
								<label class="layui-form-label">Domain：</label>
								<div class="layui-input-inline">
									<input type="text" name="m_ali_url" placeholder="请输入Domain" class="layui-input" value="{$upload.ali_url}">
								</div>
								<div class="layui-form-mid layui-word-aux"><span>*</span> 访问域名(http://或https://开头)</div>
							</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="m_footer">
			<button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-submit">提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
    </form>
</div>
</body>
</html>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '{__STATIC__}/layuiAdmin/' // 静态资源所在路径
	}).use(['index','form'], function(){
		let $ = layui.$;
		let layer = layui.layer;
		let form = layui.form;

		/* 监听select */
		form.on('select(m_location)',function (data) {
			if(data.value==1){
				$("#span_qiniu").hide();
				$("#span_qcloud").hide();
				$("#span_ali").hide();
			}
			if(data.value==2){
				$("#span_qiniu").show();
				$("#span_qcloud").hide();
				$("#span_ali").hide();
			}
			if(data.value==3){
				$("#span_qiniu").hide();
				$("#span_qcloud").show();
				$("#span_ali").hide();
			}
			if(data.value==4){
				$("#span_qiniu").hide();
				$("#span_qcloud").hide();
				$("#span_ali").show();
			}
		});

		/* 监听提交 */
		form.on('submit(LAY-submit)', function(data){
			let field = data.field; //获取提交的字段
			$.ajax({
				type:"post",
				url:"saveUpload.html",
				data: {
					uptype:field.m_uptype,
					upsize:field.m_upsize,
					uplocation:field.m_uplocation,
					qiniu_ak:field.m_qiniu_ak,
					qiniu_sk:field.m_qiniu_sk,
					qiniu_bucket:field.m_qiniu_bucket,
					qiniu_domain:field.m_qiniu_domain,
					qcloud_appId:field.m_qcloud_appId,
					qcloud_secretId:field.m_qcloud_secretId,
					qcloud_secretKey:field.m_qcloud_secretKey,
					qcloud_bucket:field.m_qcloud_bucket,
					qcloud_region:field.m_qcloud_region,
					qcloud_cosUrl:field.m_qcloud_cosUrl,
					ali_accessKeyId:field.m_ali_accessKeyId,
					ali_accessKeySecret:field.m_ali_accessKeySecret,
					ali_endpoint:field.m_ali_endpoint,
					ali_bucket:field.m_ali_bucket,
					ali_url:field.m_ali_url
				},
				dataType:"json",
				beforeSend: function () {
					layer.load(1);
				},
				success:function(res){
					layer.closeAll(); //关闭弹层
					if(res.code == 0){
						layer.msg('修改成功', {
							time: 2000
						}, function(){
							location.reload();
						});
					}
					else {
						layer.msg(res.msg);
					}
				}
			});
			return false;
		});
	});
</script>